package www.openteam.com.ui.qualityCntrl;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import www.openteam.com.R;
import www.openteam.com.adapter.qualityCntrl.FQCGoodsYeildAdp;
import www.openteam.com.bean.FQCGoodsField;
import www.openteam.com.bean.FQCGoodsInspect;
import www.openteam.com.bean.FQCHalfGoodsInspect;


public class FQCSeaechFragment extends Fragment {


    @Bind(R.id.fqc_search_recy)
    RecyclerView fqcSearchRecy;
    private FQCGoodsYeildAdp fqcGoodsYeildAdp;
    IondataClickback iondataClickback;
    private String TAG = getClass().getSimpleName();
    private List<FQCGoodsField.DataBeanX.DataBean> dataBeanList;

    public FQCSeaechFragment() {
        // Required empty public constructor
    }

    public void setIondataClickback(IondataClickback iondataClickback) {
        this.iondataClickback = iondataClickback;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_fqcseaech, container, false);
        ButterKnife.bind(this, view);
        fqcSearchRecy.setLayoutManager(new LinearLayoutManager(getContext()));
        initdata();
        return view;
    }

    private void initdata() {
        if (null==fqcGoodsYeildAdp){
            fqcGoodsYeildAdp = new FQCGoodsYeildAdp(getContext(), dataBeanList);
        }
            fqcSearchRecy.setAdapter(fqcGoodsYeildAdp);
            fqcGoodsYeildAdp.setiGoodsYeilClickBack(new FQCGoodsYeildAdp.IGoodsYeilClickBack() {

                @Override
                public void postdata(FQCGoodsField.DataBeanX.DataBean dataBean) {
                    if (iondataClickback!=null){
                        iondataClickback.onGoodsField(dataBean);
                    }
                }
            });

    }

    /**
     * 生产入库
     *
     * @param data
     */
    public void onGoodsField(FQCGoodsField data) {
        dataBeanList = data.getData().getData();


    }

    public void onGoodsInspect(FQCGoodsInspect data) {

    }

    public void onHalfGoodsInspect(FQCHalfGoodsInspect data) {

    }

    public interface IondataClickback {
        void onGoodsField(FQCGoodsField.DataBeanX.DataBean dataBean);

        void onGoodsInspect(int postion);

        void onHalfGoodsInspect(int postion);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
